package com.navinfo.tripanalysis.common.arithmetic;

import com.navinfo.tripanalysis.common.arithmetic.annotation.Arithmetic;
import com.navinfo.tripanalysis.common.arithmetic.common.CommonData;
import com.navinfo.tripanalysis.common.arithmetic.common.OuterStatisticData;
import com.navinfo.tripanalysis.common.arithmetic.common.OuterStatisticExtendedData;
import com.navinfo.tripanalysis.common.arithmetic.custom.VarRangeRotationUrea;
import com.navinfo.tripanalysis.common.arithmetic.enums.RangeRpmEnum;
import com.navinfo.tripanalysis.common.arithmetic.manager.AbstractArithmetic;
import com.navinfo.tripanalysis.common.util.ArithmeticUtils;

/**
 * 东风
 * 发动机转速区间尿素消耗统计算法<br/>
 * 输出：统计
 *
 * @author liudong
 */
@Arithmetic(name = "发动机转速区间尿素消耗")
public class RangeRotationUrea_DF extends AbstractArithmetic<VarRangeRotationUrea> {

    @Override
    public void calculate() {
        logger.debug("进入发动机转速区间尿素消耗统计算法.");
        VarRangeRotationUrea var = getObj();
        CommonData commonData = getCommonData();

        int rotation = commonData.getRotation();

        //转数有效性校验
        if (!RangeRpmEnum.RANGE_OVER_VALID.getRange().contains(rotation)) {
            return;
        }

        int urea = ArithmeticUtils.massToVolume(commonData.getUreaInjection(), commonData.getAtmosphericTem());
        if (urea == 0) {
            return;
        }
        //累加相应转速区间的统计变量
        if (RangeRpmEnum.RANGE_500.getRange().contains(rotation)) {
            var.addRpm500(urea);
        } else if (RangeRpmEnum.RANGE_600.getRange().contains(rotation)) {
            var.addRpm600(urea);
        } else if (RangeRpmEnum.RANGE_700.getRange().contains(rotation)) {
            var.addRpm700(urea);
        } else if (RangeRpmEnum.RANGE_800.getRange().contains(rotation)) {
            var.addRpm800(urea);
        } else if (RangeRpmEnum.RANGE_900.getRange().contains(rotation)) {
            var.addRpm900(urea);
        } else if (RangeRpmEnum.RANGE_1000.getRange().contains(rotation)) {
            var.addRpm1000(urea);
        } else if (RangeRpmEnum.RANGE_1100.getRange().contains(rotation)) {
            var.addRpm1100(urea);
        } else if (RangeRpmEnum.RANGE_1200.getRange().contains(rotation)) {
            var.addRpm1200(urea);
        } else if (RangeRpmEnum.RANGE_1300.getRange().contains(rotation)) {
            var.addRpm1300(urea);
        } else if (RangeRpmEnum.RANGE_1400.getRange().contains(rotation)) {
            var.addRpm1400(urea);
        } else if (RangeRpmEnum.RANGE_1500.getRange().contains(rotation)) {
            var.addRpm1500(urea);
        } else if (RangeRpmEnum.RANGE_1600.getRange().contains(rotation)) {
            var.addRpm1600(urea);
        } else if (RangeRpmEnum.RANGE_1700.getRange().contains(rotation)) {
            var.addRpm1700(urea);
        } else if (RangeRpmEnum.RANGE_1800.getRange().contains(rotation)) {
            var.addRpm1800(urea);
        } else if (RangeRpmEnum.RANGE_1900.getRange().contains(rotation)) {
            var.addRpm1900(urea);
        } else if (RangeRpmEnum.RANGE_2000.getRange().contains(rotation)) {
            var.addRpm2000(urea);
        } else if (RangeRpmEnum.RANGE_2100.getRange().contains(rotation)) {
            var.addRpm2100(urea);
        } else if (RangeRpmEnum.RANGE_2200.getRange().contains(rotation)) {
            var.addRpm2200(urea);
        } else if (RangeRpmEnum.RANGE_2300.getRange().contains(rotation)) {
            var.addRpm2300(urea);
        } else if (RangeRpmEnum.RANGE_2400.getRange().contains(rotation)) {
            var.addRpm2400(urea);
        } else if (RangeRpmEnum.RANGE_2500.getRange().contains(rotation)) {
            var.addRpm2500(urea);
        } else if (RangeRpmEnum.RANGE_2600.getRange().contains(rotation)) {
            var.addRpm2600(urea);
        } else if (RangeRpmEnum.RANGE_2700.getRange().contains(rotation)) {
            var.addRpm2700(urea);
        } else if (RangeRpmEnum.RANGE_2800.getRange().contains(rotation)) {
            var.addRpm2800(urea);
        } else if (RangeRpmEnum.RANGE_2900.getRange().contains(rotation)) {
            var.addRpm2900(urea);
        } else if (RangeRpmEnum.RANGE_3000.getRange().contains(rotation)) {
            var.addRpm3000(urea);
        } else if (RangeRpmEnum.RANGE_OVER_3000.getRange().contains(rotation)) {
            var.addRpmOver3000(urea);
        }

        logger.debug("发动机转速区间尿素消耗统计算法结束.");
    }

    @Override
    public void collect(OuterStatisticData statisticData) {
        VarRangeRotationUrea var = getObj();

        OuterStatisticExtendedData extendedData = statisticData.getExtendedData();
        extendedData.setRpmRange500Urea(var.getRpm500());
        extendedData.setRpmRange600Urea(var.getRpm600());
        extendedData.setRpmRange700Urea(var.getRpm700());
        extendedData.setRpmRange800Urea(var.getRpm800());
        extendedData.setRpmRange900Urea(var.getRpm900());
        extendedData.setRpmRange1000Urea(var.getRpm1000());
        extendedData.setRpmRange1100Urea(var.getRpm1100());
        extendedData.setRpmRange1200Urea(var.getRpm1200());
        extendedData.setRpmRange1300Urea(var.getRpm1300());
        extendedData.setRpmRange1400Urea(var.getRpm1400());
        extendedData.setRpmRange1500Urea(var.getRpm1500());
        extendedData.setRpmRange1600Urea(var.getRpm1600());
        extendedData.setRpmRange1700Urea(var.getRpm1700());
        extendedData.setRpmRange1800Urea(var.getRpm1800());
        extendedData.setRpmRange1900Urea(var.getRpm1900());
        extendedData.setRpmRange2000Urea(var.getRpm2000());
        extendedData.setRpmRange2100Urea(var.getRpm2100());
        extendedData.setRpmRange2200Urea(var.getRpm2200());
        extendedData.setRpmRange2300Urea(var.getRpm2300());
        extendedData.setRpmRange2400Urea(var.getRpm2400());
        extendedData.setRpmRange2500Urea(var.getRpm2500());
        extendedData.setRpmRange2600Urea(var.getRpm2600());
        extendedData.setRpmRange2700Urea(var.getRpm2700());
        extendedData.setRpmRange2800Urea(var.getRpm2800());
        extendedData.setRpmRange2900Urea(var.getRpm2900());
        extendedData.setRpmRange3000Urea(var.getRpm3000());
        extendedData.setRpmRangeOver3000Urea(var.getRpmOver3000());
    }
}
